Software Development
Parameterize Types Using Generics
Generics in Java: Bounded Type Parameters & Wildcards
Generics in Java: Creating Classes and Methods Using Generics

Generics in Java: Bounded Type Parameters & Wildcards

Course Number:
it_jpptgedj_02_enus
Lesson Objectives

Generics in Java: Bounded Type Parameters & Wildcards

  • discover the key concepts covered in this course
  • recall the disadvantages of unbounded type parameters
  • constrain types using bounded type parameters
  • specify type parameters with interface bounds
  • use bounded type parameters with custom objects
  • use multiple bounds with type parameters
  • use upper-bounded wildcards
  • compare and contrast upper-bounded wildcards and bounded type parameters
  • recall when and how you would use unbounded wildcards
  • use unbounded wildcards
  • use lower-bounded wildcards
  • recall how Java infers data types using wildcard capture
  • recall the structure of valid type parameter names
  • recall how the Java compiler uses type erasure with generic types
  • summarize the key concepts covered in this course

Overview/Description
In Java, bounded type parameters and wildcards offer certain flexibility and disadvantages. Recognizing these will help you decide when and how to use these tools to your advantage when writing code. Use this course to get to grips with what's meant by unbounded and bounded type parameters, explore the use of wildcards in Java, and recognize the applications of unbounded, upper-bounded, and lower-bounded wildcards. As you advance, investigate what's meant by 'wildcard capture' and 'type erasure.' When you're finished, you'll be able to correctly identify scenarios for using bounded type parameters and wildcards and implement them correctly.

Target

Prerequisites: none

Generics in Java: Creating Classes and Methods Using Generics

Course Number:
it_jpptgedj_01_enus
Lesson Objectives

Generics in Java: Creating Classes and Methods Using Generics

  • discover the key concepts covered in this course
  • list the advantages of writing generic code over non-generic code
  • recall the limitations on code reuse in non-generic classes
  • recall the limitations of using raw objects rather than generic types
  • implement a class with generics for type safety and compile-time checks
  • use generic types as input arguments to methods and return values from methods
  • create non-parameterized objects from generic classes
  • recall the disadvantages of non-generic methods
  • parameterize the class definition to create generic methods
  • parameterize the method definition without parameterizing classes
  • illustrate type inference with parameterized methods
  • summarize the key concepts covered in this course

Overview/Description
Generics is a handy tool in Java that greatly increases the maintainability of your code by allowing you to reuse code, using the same class or method with different types of data. Furthermore, generics also convert runtime checks to compile-time checks, making your code less error-prone. In this course, learn how to use generics in Java to write reusable and maintainable code, exploring why generic code has several advantages over non-generic code. Get hands-on practice with creating and defining classes with generic type parameters. Investigate how these generic types can be used as types for member variables, input arguments to methods, and return values from methods. Moving along, implement generic methods where the generic type parameter is associated with the method rather than the class itself. When you're finished, you'll have a solid foundation in defining and working with generic classes and methods in Java.

Target

Prerequisites: none

Close Chat Live